package com.summer.classLoader;

import java.net.URL;
import java.net.URLClassLoader;

public class VersionLoaderTest {
	
	public static void main(String[] args) throws Exception { 
//        String v1dir = "file:///Users/qianwp/source/jcl/v1/"; 
//        String v2dir = "file:///Users/qianwp/source/jcl/v2/"; 
        String v1dir = "file:///D:/javaProject/Test/bin/com/summer/classLoader/v1"; 
        String v2dir = "file:///D:/javaProject/Test/bin/com/summer/classLoader/v2"; 

        URLClassLoader v1 = new URLClassLoader(new URL[]{new URL(v1dir)}); 
        URLClassLoader v2 = new URLClassLoader(new URL[]{new URL(v2dir)}); 

        Class<?> versionModel1Class = v1.loadClass("com.summer.classLoader.v1.VersionModel"); 
        Object versionModel1 = versionModel1Class.getConstructor().newInstance(); 
        versionModel1Class.getMethod("println").invoke(versionModel1); 

        Class<?> versionModel2Class = v2.loadClass("com.summer.classLoader.v2.VersionModel"); 
        Object versionModel2 = versionModel2Class.getConstructor().newInstance(); 
        versionModel2Class.getMethod("println").invoke(versionModel2);  
        
        System.out.println(versionModel1Class.equals(versionModel2Class)); 
    }
	
}
